package com.day7.test5_objects;

import java.util.Objects;

/**
 * @author 小坡
 * @date 2022/9/10  17:23
 **/
public class TestObjects {
    public static void main(String[] args) {
//      public static String toString(对象)
//                返回参数中对象的字符串表示形式
        Student student = new Student("张三", 23);
        String s = Objects.toString(student);
        System.out.println(s);//效果一样
        System.out.println(student);//效果一样


//        public static String toString(对象，默认字符串)
//        返回对象的字符串表示形式。
//        返回对象的字符串表示形式。如果对象为空,那么返回第二个参数
        Student student1 = new Student("李四", 24);
        Student student2 = null;
        String result1 = Objects.toString(student1, "随便写一个");
        String result2 = Objects.toString(student2, "随便写一个");
        System.out.println(result1);
        System.out.println(result2);


//        public static Boolean isNul1(对象)
//                判断对象是否为空
        Student student3 = null;
        Student student4 = new Student();
        boolean result3 = Objects.isNull(student3);
        boolean result4 = Objects.isNull(student4);
        System.out.println(result3);
        System.out.println(result4);


//        public static Boolean nonNu11(对象)
//                判断对象是否不为空
        Student student5=new Student();
        Student student6=null;
        boolean result5=Objects.nonNull(student5);
        boolean result6=Objects.nonNull(student6);
        System.out.println(result5);
        System.out.println(result6);

    }
}
